package qeb.handheldmedical.approval;

import qeb.handheldmedical.R;
import qeb.handheldmedical.model.User;
import android.app.Activity;
import android.content.Intent;
import android.opengl.Visibility;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

/**
 * @author 作者(dugaoyi) E-mail:dugaoyi@163.com
 * @version 创建时间：2016年10月20日 上午10:58:47
 * @declaration 审批主界面
 */
public class ApprovalMain extends Activity {

	private Button btnsswsp, btnssysp, btnsscxbz, btnsscxbq;
	Button btn_title_back, btn_title_right;
	private TextView tv_top_title;
	User usr = new User();

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.app.Activity#onCreate(android.os.Bundle)
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.approval_main);
		usr = (User) getIntent().getSerializableExtra("userinfo");
		initUI();
	}

	/**
	 * UI加载
	 */
	protected void initUI() {
		btn_title_back = (Button) findViewById(R.id.btn_title_back);
		btn_title_back.setOnClickListener(MyOnClickListener);
		btn_title_right = (Button) findViewById(R.id.btn_title_right);
		btn_title_back.setVisibility(View.GONE);
		btn_title_right.setVisibility(View.GONE);
		btn_title_right.setOnClickListener(MyOnClickListener);
		tv_top_title = (TextView) findViewById(R.id.tv_top_title);
		tv_top_title.setText("审批");

		btnsswsp = (Button) findViewById(R.id.btnsswsp);
		btnsswsp.setOnClickListener(MyOnClickListener);
		btnssysp = (Button) findViewById(R.id.btnssysp);
		btnssysp.setOnClickListener(MyOnClickListener);

		btnsscxbz = (Button) findViewById(R.id.btnsscxbz);
		btnsscxbz.setOnClickListener(MyOnClickListener);

		btnsscxbq = (Button) findViewById(R.id.btnsscxbq);
		btnsscxbq.setOnClickListener(MyOnClickListener);
	}

	private OnClickListener MyOnClickListener = new OnClickListener() {

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			Intent intent = new Intent();
			switch (v.getId()) {
			// 退回
			case R.id.btn_title_back:
				ApprovalMain.this.finish();
				break;
			// 手术未审批
			case R.id.btnsswsp:
				intent = new Intent(
						ApprovalMain.this,
						qeb.handheldmedical.approval.ApprovalOperationPatients.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				intent.putExtra("userinfo", usr);
				intent.putExtra("splx", "0");
				ApprovalMain.this.getApplicationContext().startActivity(intent);
				break;
			// 手术已审批
			case R.id.btnssysp:
				intent = new Intent(
						ApprovalMain.this,
						qeb.handheldmedical.approval.ApprovalOperationPatients.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				intent.putExtra("userinfo", usr);
				intent.putExtra("splx", "1");
				ApprovalMain.this.getApplicationContext().startActivity(intent);
				break;
			// 手术本组
			case R.id.btnsscxbz:
				intent = new Intent(
						ApprovalMain.this,
						qeb.handheldmedical.approval.ApprovalOperationPatients.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				intent.putExtra("userinfo", usr);
				intent.putExtra("splx", "2");
				ApprovalMain.this.getApplicationContext().startActivity(intent);
				break;
			// 手术病区
			case R.id.btnsscxbq:
				intent = new Intent(
						ApprovalMain.this,
						qeb.handheldmedical.approval.ApprovalOperationPatients.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				intent.putExtra("userinfo", usr);
				intent.putExtra("splx", "3");
				ApprovalMain.this.getApplicationContext().startActivity(intent);
				break;
			default:
				break;
			}
		}
	};
}
